﻿using Entity.Car_Rental;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Entity;
using Data.Car_Rental;
namespace Car_Rental.Controllers
{
    public class LeaveMsgController : Controller
    {
        Car_RentalRepository<LevelMsg> db = new Car_RentalRepository<LevelMsg>();

        //
        // GET: /LeaveMsg/

        public ActionResult Index(int? page)
        {
            var model = new PagedList<LevelMsg>(db.GetModel().Where(i => i.Status == 100), page ?? 1, 10);
            return View(model);
        }

        public ActionResult Create(FormCollection form)
        {
            LevelMsg entity = new LevelMsg
            {
                Title = form["Title"],
                CreateDate = DateTime.Now,
                FromUser = Convert.ToInt32(Session["UserID"]),
                Info = form["Content"],
                Status = 100,
                UpdateDate = DateTime.Now,
            };
            db.Insert(entity);
            return RedirectToAction("Index");
        }

    }
}
